import { logError, logWarn } from "./Log";
import { LayerType } from "../const/LayerType";
// 图层集合
let LayerClass = {};

export function register(type, layerclass) {
  if (LayerClass[type]) {
    logError(`图层类型已存在，type：${type}`);
  }
  LayerType[type] = type;
  LayerClass[type] = layerclass;
  LayerClass._type = type;
}

export function getClass(type) {
  return LayerClass[type]
}

export function createLayer(options) {
  let ThisLayer = getClass(options.type)

  if (ThisLayer) {
    let layer = new ThisLayer(options)
    return layer
  } else {
    logWarn('配置中的图层未处理', options)
  }
}
